/*******************************************************************************
 *
 *    Copyright (c) Baina Info Tech Co. Ltd
 *
 *    BrowseFaster
 *    
 *    SharePreferenceManager
 *    TODO File description or class description.
 *
 *    @author: zuochen
 *    @since:  2010-10-7
 *    @version: 1.0
 *
 ******************************************************************************/

package small.hero.perprecemanager;

import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.preference.PreferenceManager;

/**
 * SharePreferenceManager of BrowseFaster.
 * 
 * @author zuochen
 * 
 */

public class SharePreferenceManager {
	private final static String TEXT_SETTING = "text setting";
	private final static String TEXT_COLOR = "text color";
	private final static String BACKGROUND_COLOR = "background color";
	Context mContext;
	SharedPreferences mSharedPreferences;

	public SharePreferenceManager(Context mContext) {
		this.mContext = mContext;
		mSharedPreferences = PreferenceManager
				.getDefaultSharedPreferences(mContext);
	}

	/**
	 * Get dialog option settings.
	 * 
	 * @return 1 means need dialog. 0 means not.
	 */
	public int getTextSizeSetting() {
		return mSharedPreferences.getInt(TEXT_SETTING, 1);
	}

	/**
	 * Set dialog option settings.
	 */
	public void setTextSizeSetting(int optionSettings) {
		Editor mEditor = mSharedPreferences.edit();
		mEditor.putInt(TEXT_SETTING, optionSettings);
		mEditor.commit();
	}

	public int getTextColorSetting() {
		return mSharedPreferences.getInt(TEXT_COLOR, 3);
	}

	/**
	 * Set dialog option settings.
	 */
	public void setTextColorSetting(int optionSettings) {
		Editor mEditor = mSharedPreferences.edit();
		mEditor.putInt(TEXT_COLOR, optionSettings);
		mEditor.commit();
	}

	public int getTextBackgroundSetting() {
		return mSharedPreferences.getInt(BACKGROUND_COLOR, 4);
	}

	/**
	 * Set dialog option settings.
	 */
	public void setTextBackgroundSetting(int optionSettings) {
		Editor mEditor = mSharedPreferences.edit();
		mEditor.putInt(BACKGROUND_COLOR, optionSettings);
		mEditor.commit();
	}
}
